import { createRouter,createWebHistory} from "vue-router";


// 本地静态路由
export const constantRoutes = [
    {
      path: '/',
      redirect: '/home/system/user'
    },
    {
        path: '/home',
        component: () => import('../view/home/Index.vue'),
        meta: {
            title: '首页'
        },
        children: [
            {
                path: 'system/user',
                component: () => import('../view/home/system/User.vue'),
                meta: {
                    title: '用户管理'
                }
            },
            {
                path: 'system/dictionary',
                component: () => import('../view/home/system/Dictionary.vue')
            },
            {
                path: 'system/role',
                component: () => import('../view/home/system/Dictionary.vue')
            },
            {
                path: 'system/permission',
                component: () => import('../view/home/system/Permission.vue')
            },
            {
                path: 'system/test',
                component: () => import('../view/home/system/Test.vue')
            }
        ]
    },
    {
        path: '/user',
        component: () => import('../view/home/Index.vue'),
        meta: {
            title: '用户管理'
        },
        children: [
            {
                path: 'list',
                component: () => import('../view/user/User.vue'),
                meta: {
                    title: '用户列表'
                }
            }
        ]
    },
    {
        path: '/role',
        component: () => import('../view/home/Index.vue'),
        meta: {
            title: '角色管理'
        },
        children: [
            {
                path: 'list',
                component: () => import('../view/role/Role.vue'),
                meta: {
                    title: '角色列表'
                }
            },
            {
                path: ':userId',
                component: () => import('../view/role/UserRole.vue'),
                meta: {
                    title: '用户角色'
                }
            }
        ]
    },
    {
        path: '/permission',
        component: () => import('../view/home/Index.vue'),
        meta: {
            title: '权限管理'
        },
        children: [
            {
                path: 'list',
                component: () => import('../view/permission/Permission.vue'),
                meta: {
                    title: '权限列表'
                }
            }
        ]
    },
    {
        path: '/system',
        component: () => import('@/view/home/Index.vue'),
        meta: {
            title: '系统管理'
        },
        children: [
            {
                path: 'dictionary',
                component: () => import('@/view/system/Dictionary.vue'),
                meta: {
                    title: '字典管理'
                }
            },
            {
                path: 'test',
                component: () => import('@/view/system/Test.vue'),
                meta: {
                    title: '测试'
                }
            }
        ]
    },
    {
        path: '/login',
        component: () => import('../view/login/Login.vue'),
        meta: {
            title: '登录'
        }
    }
];

// 创建路由
const router = createRouter({
    history: createWebHistory(),
    routes: constantRoutes,
});


export default router;